<case value="files">
    <div id="[type]{$group_k}_upload_{$[type]k}" {$[type]form.extra_attr}></div>
    <div id="[type]{$group_k}_preview_{$[type]k}">
        <input type="hidden" name="{$[type]form.name}" value="{$[type]form.value}">
        <ul class="list-group file-box">
            <notempty name="[type]form.value">
                <?php $files = explode(',',$[type]form['value']); ?>
                <foreach name="files" item="file">
                    <li class="list-group-item file-item" data-id="{$file}">
                        <i class="fa fa-file"></i> 
                        <span>{$file|get_upload_info='name'}</span> 
                        <i class="fa fa-times-circle remove-file"></i>
                    </li>
                </foreach>
            </notempty>
        </ul>
    </div>
    <script type="text/javascript">
        $(function(){
            $('#[type]{$group_k}_upload_{$[type]k}').Huploadify({
                uploader:'{:U(C("MODULE_MARK")."/PublicUpload/upload")}',
                fileTypeExts:'*.gif;*.jpg;*.jpeg;*.png;'+
                             '*.swf;*.flv;*.mp3;*.wav;*.wma;*.wmv;*.mid;*.avi;*.mpg;*.asf;*.rm;*.rmvb;*.mp4;'+
                             '*.doc;*.docx;*.xls;*.xlsx;*.ppt;*.pptx;*.pdf;*.wps;*.txt;*.zip;*.rar;*.gz;*.bz2;*.7z',
                fileSizeLimit:{:C('UPLOAD_FILE_SIZE')}*1024,
                buttonText:'添加文件',
                onUploadComplete:function(file, data){
                    var data = $.parseJSON(data);
                    if(data.error == 1){
                        $.alertMessager(data.message, 'danger');
                    }else{
                        var new_file = '<li class="list-group-item file-item" data-id="'+data.id+'"><i class="fa fa-file"></i> '
                                       +data.name+' <i class="fa fa-times-circle remove-file"></i></li>'
                        $('#[type]{$group_k}_preview_{$[type]k} .list-group').append(new_file);
                        var input = $('#[type]{$group_k}_preview_{$[type]k} input');
                        if(input.val() != ''){
                            input.val(input.val() + ',' + data.id);
                        }else{
                            input.val(data.id);
                        }
                    }
                }
            });
            //删除文件
            $(document).on('click', '#[type]{$group_k}_preview_{$[type]k} .remove-file', function() {
                var ready_for_remove_id = $(this).closest('.file-item').attr('data-id'); //获取待删除的文件ID
                if(!ready_for_remove_id) {
                    $.alertMessager('错误', 'danger');
                }
                var current_file_ids = $('#[type]{$group_k}_preview_{$[type]k} input').val().split(","); //获取当前文件列表以逗号分隔的ID并转换成数组
                current_file_ids.remove(ready_for_remove_id); //从数组中删除待删除的文件ID
                $('#[type]{$group_k}_preview_{$[type]k} input').val(current_file_ids.join(',')) //删除后覆盖原input的值
                $(this).closest('.file-item').remove(); //删除文件预览
            });
        });
    </script>
</case>